#ifndef Renderer_h__
#define Renderer_h__

#include "Platform.h"
#include "TypeWrap.h"
#include <vector>

#define SAFE_RELEASE(x) if(x) { x->Release(); x = NULL; }

TYPE_WRAP(uint32, TextureID);
TYPE_WRAP(uint32, ShaderID);

namespace le
{
	class Path;
	class ShaderProgram;
	class Camera;
	class Model;
	struct StartupStruct;
}

struct SDL_Window;
typedef void* SDL_GLContext;

namespace le
{
	class Renderer
	{
	public:
		Renderer();
		virtual ~Renderer();

		void CreateRenderer(const le::StartupStruct& startupStruct);
		void DestroyRenderer();

		void Clear(float r, float g, float b, float alpha);
		void Present();
		void RenderModel(const le::Model* model);

		/** Ownership of the ShaderProgram transfers to the caller. */
		le::ShaderProgram* CreateShader(const le::Path& vs, const le::Path& fs);

		void MakeShaderActive(const uint32 shaderProgramId);

		le::Camera* GetActiveCamera() const {return m_Camera;}

		// TODO - Make this something nicer like load from a file or so.
		virtual le::Model* CreateModel();

	protected:
		
		virtual void SwapWindow();

	protected:
		std::vector<TextureID> m_Textures;

		le::Camera* m_Camera;

	private:
		SDL_Window* m_Window;
		SDL_GLContext m_Context;

	};
}

#endif // Renderer_h__